package com.dao.impl;

import com.dao.TypeDao;
import com.entity.Type;
import com.utils.ConnectionUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @ProjectName: shop
 * @Author: Jsx
 * @Time: 2020/8/30 20:00
 * @Description:
 */
public class TypeDaoImpl implements TypeDao {
    @Override
    public List<Type> queryTypes(int num) throws SQLException {

        String sql ="select t_id tid ,t_name tname,t_info tinfo from type limit ?";

        QueryRunner queryRunner = new QueryRunner(ConnectionUtils.getDataSource());

        List<Type> types = queryRunner.query(sql,new BeanListHandler<Type>(Type.class) ,num);

        return types;
    }
}
